hvm: Fix PV-on-HVM drivers to not execuite hypercall page while it is
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 6 Aug 2007 10:16:14 +0000 (11:16 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 6 Aug 2007 10:16:14 +0000 (11:16 +0100)
being re-initialised.
Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c

index 15ceef8da651d2393683551675f1640c79b1f0dd..bd58d2ceb5c4e8ba53c1df72c949af50fa36bb59 100644 (file)
@@ -11,6 +11,12 @@ struct ap_suspend_info {
        atomic_t nr_spinning;
 };
 
+/*
+ * Use a rwlock to protect the hypercall page from being executed in AP context
+ * while the BSP is re-initializing it after restore.
+ */
+static DEFINE_RWLOCK(suspend_lock);
+
 /*
  * Spinning prevents, for example, APs touching grant table entries while
  * the shared grant table is not mapped into the address space imemdiately
@@ -27,7 +33,9 @@ static void ap_suspend(void *_info)
 
        while (info->do_spin) {
                cpu_relax();
+               read_lock(&suspend_lock);
                HYPERVISOR_yield();
+               read_unlock(&suspend_lock);
        }
 
        mb();
@@ -43,7 +51,9 @@ static int bp_suspend(void)
        suspend_cancelled = HYPERVISOR_shutdown(SHUTDOWN_suspend);
 
        if (!suspend_cancelled) {
+               write_lock(&suspend_lock);
                platform_pci_resume();
+               write_unlock(&suspend_lock);
                gnttab_resume();
                irq_resume();
        }